package toster;

/**
 *Formats and displays the output
 * @author rcluster
 */
public class Output {

    /**
     *
     * @param grid
     * @param split
     */
    public static void printPicture(int[][] grid, boolean split) {
        int x, colLen = grid.length, rowLen = grid[0].length;
        String s;
        for (int i = 0; i < colLen; i++) {
            for (int j = 0; j < rowLen; j++) {
                x = grid[i][j];
                if (x == Function.filled) s = "█";
                else if (x == Function.empty) s = "-";
                else s = ".";
                System.out.print(s + " ");
                if ((j+1)%5 == 0 && split) System.out.print(" ");
            }
            System.out.println();
            if ((i+1)%5 == 0 && split) System.out.println();
        }

    }
    /**
     * Prints out a grid of the 2D boolean array you give it and splits it if
     * given true
     * @param grid, grid you want printed out
     * @param split, if you want it split or not
     */

    public static void printPicture(boolean[][] grid, boolean split) {
        int len = grid.length, rlen;
        int[][] g = new int[len][];
        for (int i = 0; i < len; i++) {
            rlen = grid[i].length;
            g[i] = new int[rlen];
            for (int j = 0; j < rlen; j++) {
                if (grid[i][j]) g[i][j] = Function.filled;
                else g[i][j] = 0;
            }
        }
        printPicture(g, split);
    }
    /**
     * Prints out final grid of the input 2D array
     * @param in, array you want printed
     */

    public Output(boolean[][] in){
        printPicture(in, true);
    }
}
